#! /usr/bin/python
import sys
import os

rate=1
dn=1
fn=1
cmd = ""
result=""

cmd="mkdir result"
os.system(cmd)

cmd="mkdir result/time"
os.system(cmd)

cmd="mkdir result/event"
os.system(cmd)

cmd="mkdir result/cpu"
os.system(cmd)

for dn in [1,2,4,8,16,32,64,128]:
    cmd= "rm -rf dimTable* factTable*"
    os.system(cmd)
    cmd = "./joinGen 10 " + str(dn) + " " +str(fn)+ " 2 2 "
    os.system(cmd)
    cmd = "chmod 777 dimTable* factTable*"
    os.system(cmd)
    result = "result/time/" + str(dn)+"_noprof" 
    cmd = "./joinTest factTable dimTable 2 2  > " + result 
    os.system(cmd)
    os.system(cmd)

    result = "result/time/" + str(dn) 
    cmd = "nvprof ./joinTest factTable dimTable 2 2  > " + result 
    os.system(cmd)
    os.system(cmd)

    result = "result/cpu/" + str(dn) 
    cmd = "./joinCpu factTable dimTable 2 2  > " + result 
    os.system(cmd)

    result = "result/event/" + str(dn) + "_mem_request" 
    cmd = "nvprof --events gld_request,gst_request ./joinTest factTable dimTable 2 2  > " + result 
    os.system(cmd)

    result = "result/event/" + str(dn) + "_mem_ld_transaction" 
    cmd = "nvprof --events l1_global_load_hit,l1_global_load_miss ./joinTest factTable dimTable 2 2  > " + result 
    os.system(cmd)

    result = "result/event/" + str(dn) + "_mem_st_transaction" 
    cmd = "nvprof --events global_store_transaction ./joinTest factTable dimTable 2 2  > " + result 
    os.system(cmd)

    result = "result/event/" + str(dn) + "_inst" 
    cmd = "nvprof --events inst_issued,inst_executed ./joinTest factTable dimTable 2 2  > " + result 
    os.system(cmd)

cmd= "rm -rf dimTable* factTable*"
os.system(cmd)
